package com.mofang.powerdekorhelper.adapter;

import android.content.Context;
import android.view.View;

import com.mofang.powerdekorhelper.R;
import com.mofang.powerdekorhelper.base.recycleview.BaseRecycleViewAdapter;
import com.mofang.powerdekorhelper.base.recycleview.BaseViewHolder;
import com.mofang.powerdekorhelper.model.CustomerDetail;

import java.util.List;

/**
 * Created by luofei on 2017/9/2 0002.
 * 说明：
 */

public class CommunicationRecordAdapter extends BaseRecycleViewAdapter {

    public CommunicationRecordAdapter(List<?> data, Context mContext, int layoutId) {
        super(data, mContext, layoutId);
    }

    @Override
    protected <T> void convert(BaseViewHolder holder, T bean, int position) {

        CustomerDetail.CustomerCommunication communication = (CustomerDetail.CustomerCommunication) bean;

        if (position == 0) {
            holder.setImageResouse(R.id.communication_process_imv, R.mipmap.process_current_icon);
        } else {
            holder.setImageResouse(R.id.communication_process_imv, R.mipmap.process_icon);
        }
        holder.setText(R.id.communication_time_tv, communication.getCommunicate_time());
        holder.setText(R.id.communication_content_tv, communication.getCommunicate_content());

        int state = communication.getState();
        String stateStr = "";
        switch (state) {
            case 1:
                stateStr = "已联系";
                break;
            case 2:
                stateStr = "已进店";
                break;
            case 3:
                stateStr = "已购卡";
                break;
            case 4:
                stateStr = "已订单";
                break;
            case 5:
                stateStr = "已活动";
                break;
            case 6:
                stateStr = "已物流";
                break;
            case 7:
                stateStr = "已安装";
                break;
            case 8:
                stateStr = "售后中";
                break;
            case 9:
                stateStr = "已关闭";
                break;
        }
        holder.setText(R.id.communication_state_tv, stateStr);

        if (position == 0) {
            holder.setViewVisiable(R.id.communication_process_flag1, View.INVISIBLE);
        } else {
            holder.setViewVisiable(R.id.communication_process_flag1, View.VISIBLE);
        }

        if (position == mData.size() - 1) {
            holder.setViewVisiable(R.id.communication_process_flag2, View.INVISIBLE);
        } else {
            holder.setViewVisiable(R.id.communication_process_flag2, View.VISIBLE);
        }
    }
}
